package com.fy.springcloud.feign.fallback;

import com.fy.springcloud.feign.GoodsServiceFeign;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Slf4j
@Component
public class GoodsServiceFeignFallbackFactory implements FallbackFactory<GoodsServiceFeign> {
    @Override
    public GoodsServiceFeign create(Throwable throwable) {
        return new GoodsServiceFeign() {

            @Override
            public List<String> getGoodsList() {
                log.info("GoodsServiceFeignFallbackFactory throws message: {}", throwable.getMessage());
                return Collections.singletonList("exception");
            }
        };
    }
}
